package com.rdc.qingkou.presenter;


import com.rdc.qingkou.base.BasePresenterImpl;
import com.rdc.qingkou.model.BrowseDetailModel;
import com.rdc.qingkou.model.imodel.IBrowseDetailModel;
import com.rdc.qingkou.presenter.ipresenter.IBrowseDetailPresenter;
import com.rdc.qingkou.ui.iview.IBrowseDetailView;


public class BrowseDetailPresenter extends BasePresenterImpl<IBrowseDetailView> implements IBrowseDetailPresenter {


    private IBrowseDetailModel model;

    public BrowseDetailPresenter() {
        model = new BrowseDetailModel(this);
    }


    @Override
    public void getCardStatus(int userId, int cardId) {
        model.getCardStatus(userId, cardId);
    }

    @Override
    public void getCardStatusSuccess(boolean isCollected, boolean isAppreciated) {
        if (isAppreciated) {
            getMvpView().setCardStatus(isCollected, isAppreciated);
        }
    }

    @Override
    public void getCardStatusError(String message) {
        if (isAttachView()) {
            getMvpView().getCardStatusError(message);
        }
    }

    @Override
    public void appreciate(int userId, int cardId) {
        model.appreciate(userId, cardId);
    }

    @Override
    public void cancelAppreciate(int userId, int cardId) {
        model.cancelAppreciate(userId, cardId);
    }

    @Override
    public void appreciateError(String message) {
        if (isAttachView()) {
            getMvpView().appreciateError(message);
        }
    }

    @Override
    public void appreciateSuccess(boolean isAppreciated) {
        if (isAttachView()) {
            getMvpView().appreciateSuccess(isAppreciated);
        }
    }

    @Override
    public void collect(int userId, int cardId) {
        model.collect(userId, cardId);
    }

    @Override
    public void cancelCollect(int userId, int cardId) {
        model.cancelCollect(userId, cardId);
    }

    @Override
    public void collectError(String message) {
        if (isAttachView()) {
            getMvpView().collectError(message);
        }
    }

    @Override
    public void collectSuccess(boolean isCollected) {
        if (isAttachView()) {
            getMvpView().collectSuccess(isCollected);
        }
    }

    @Override
    public void deleteCard(int cardId) {
        model.deleteCard(cardId);
    }

    @Override
    public void deleteCardResult(String message, boolean isSuccess) {
        if (isAttachView()) {
            getMvpView().deleteCardResult(message, isSuccess);
        }
    }

    @Override
    public void clearDisposable() {
        model.clearDisposable();
    }
}
